<?php

namespace App\Http\Controllers\API\Admin;

use App\Http\Requests\CreateCategoryRequest;
use App\Http\Requests\UpdateCategoryRequest;
use App\Models\Category;
use App\Models\Navigate;
use App\Repositories\CategoryRepository;
use App\Http\Controllers\AppBaseController;
use App\Repositories\NavigateRepository;
use App\Repositories\PicturesRepository;
use App\ZL\Controllers\ApiBaseController;
use Illuminate\Http\Request;
use Flash;
use Illuminate\Support\Facades\Auth;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;

class NavigateAPIAdminController extends ApiBaseController
{
    private $navigateRepository;
    protected $model_name = 'App\Models\Navigate';
    protected $model_load_array = [
    ];
    protected $search_field_array = [
    ];

    public function __construct(NavigateRepository $navigateRepository)
    {
        $this->navigateRepository = $navigateRepository;
    }


    public function authLimit()
    {
        $shop = Auth::guard('admin')->user()->shop;
        $limit = [];
        $limit[] = ['shop_id', $shop->id];
        return $limit;
    }

    public function beforeStore($id, $request)
    {
        $shop = Auth::guard('admin')->user()->shop;
        $model = $this->getModel();
        $obj = $model->find($id);
        $obj->shop_id = $shop->id;
        $obj->save();
        return responseZK(1,$obj);
    }

    public function beforeUpdate($id, $request)
    {
        $shop = Auth::guard('admin')->user()->shop;
        $model = $this->getModel();
        $obj = $model->find($id);
        $obj->shop_id = $shop->id;
        $obj->save();
        return responseZK(1,$obj);
    }
}
